/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.shop.service;

import java.util.List;

import com.thinkgem.jeesite.modules.shop.entity.Reply;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.modules.shop.entity.Comments;
import com.thinkgem.jeesite.modules.shop.dao.CommentsDao;

/**
 * 评论Service
 * @author 马勇强
 * @version 2019-05-20
 */
@Service
@Transactional(readOnly = true)
public class CommentsService extends CrudService<CommentsDao, Comments> {

	@Autowired
	private ReplyService replyService;

	public Comments get(String id) {
		return super.get(id);
	}
	
	public List<Comments> findList(Comments comments) {
		List<Comments> commentsList=super.findList(comments);
		for (Comments com: commentsList) {
			Reply reply = new Reply();
			reply.setComments(com);
			List<Reply> list = replyService.findListById(reply.getComments().getId());
			com.setReplyList(list);
		}
		return commentsList;
	}
	
	public Page<Comments> findPage(Page<Comments> page, Comments comments) {
		return super.findPage(page, comments);
	}
	
	@Transactional(readOnly = false)
	public void save(Comments comments) {
		super.save(comments);
	}
	
	@Transactional(readOnly = false)
	public void delete(Comments comments) {
		super.delete(comments);
	}
	
}